package com.mangguo.tingjian.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mangguo.tingjian.user.controller.req.UserImageReq;
import com.mangguo.tingjian.user.dto.*;
import com.mangguo.tingjian.user.entity.DwUserActiveApp;
import com.mangguo.tingjian.user.mapper.DwUserActiveAppMapper;
import com.mangguo.tingjian.user.service.IDwUserActiveAppService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 激活用户-APP 服务实现类
 * </p>
 *
 * @author auto
 * @since 2019-11-23
 */
@Service
@AllArgsConstructor
public class DwUserActiveAppServiceImpl extends ServiceImpl<DwUserActiveAppMapper, DwUserActiveApp> implements IDwUserActiveAppService {

    private final DwUserActiveAppMapper dwUserActiveAppMapper;

    @Override
    public Long countAllUniqueImei() {
        return dwUserActiveAppMapper.countAllUniqueImei();
    }

    @Override
    public Long countUniqueImeiBetweenDate(Integer start, Integer end) {
        return dwUserActiveAppMapper.countUniqueImeiBetweenDate(start, end);
    }

    @Override
    public List<CountResult> countUniqueImeiByDateBetweenDate(UserImageReq userImageReq) {
        return dwUserActiveAppMapper.countUniqueImeiByDateBetweenDate(userImageReq);
    }

    @Override
    public List<ChannelResult> countUniqueImeiByChannelIdBetweenDate(UserImageReq userImageReq) {
        List<ChannelResult> list = dwUserActiveAppMapper.countUniqueImeiByChannelIdBetweenDate(userImageReq);
        list.addAll(dwUserActiveAppMapper.countUniqueImeiBySubchannelIdBetweenDate(userImageReq));
        if(list.size() < 5){
            return list;
        }
        return list.subList(0, 5);
    }

    @Override
    public List<CityResult> countUniqueImeiByCityBetweenDate(UserImageReq userImageReq) {
        return dwUserActiveAppMapper.countUniqueImeiByCityBetweenDate(userImageReq);
    }

    @Override
    public List<ProvinceResult> countUniqueImeiByProvinceBetweenDate(UserImageReq userImageReq) {
        return dwUserActiveAppMapper.countUniqueImeiByProvinceBetweenDate(userImageReq);
    }

    @Override
    public List<PlatformResult> countUniqueImeiByPlatformBetweenDate(UserImageReq userImageReq) {
        return dwUserActiveAppMapper.countUniqueImeiByPlatformBetweenDate(userImageReq);
    }

    @Override
    public List<SystemResult> countUniqueImeiBySystemBetweenDate(UserImageReq userImageReq) {
        return dwUserActiveAppMapper.countUniqueImeiBySystemBetweenDate(userImageReq);
    }

    @Override
    public List<CountResult> countUniqueImeiByMonth() {
        return dwUserActiveAppMapper.countUniqueImeiByMonth();
    }

    @Override
    public List<CountResult> countUniqueImeiByDate(Integer start, Integer end) {
        return dwUserActiveAppMapper.countUniqueImeiByDate(start, end);
    }
}
